﻿using System;
using System.Collections.Generic;
using FriendsNearby.Services.Entities;
using InSTEDD.Labs.Geo;
using System.Linq.Expressions;

namespace FriendsNearby.Services
{
    public interface IDataAccess
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="facebookUserID"></param>
        /// <param name="sessionKey"></param>
        /// <param name="displayName"></param>
        /// <returns>true if no registration of <paramref name="facebookUserID"/> was found.</returns>
        bool EnsureUserExists(string facebookUserID, string sessionKey, string displayName);
        void RemoveUserRegistry(string userId);
        void AddFacebookIdentity(Guid userID, string facebookUserID, string facebookSessionKey, string displayName);
        string GetUserSessionKey(string userId);
        IEnumerable<string> GetAllTwitterUserIds();
        void SetUserPreferences(Guid userID, string twitterScreenName, int nearbyRadiusKM, VisibilityLevel visibilityLevel);
        UserRegistry QueryUserRegistry(Expression<Func<UserRegistry, bool>> filter);
        UserRegistry ReadUserPreferences(Guid userId);

        void AddSocialEntryLog(Guid userID, DateTime timeStamp, int friendsBeforeMove, int friendsAfterMove);
        IEnumerable<Guid> GetMovedUsers(DateTime since);

        LocationInfo GetCurrentUserLocation(Guid userID);
        void UpdateUserLocation(Guid userID, LatLong location);
        // TODO refactor or use GetUserLocation(Guid, DateTime);
        // bool GetLastLocationInfo(Guid userID, out LatLong location, out DateTime date);
        UserLocationHistory GetUserLocation(Guid userID, DateTime pointInTime);

        void SaveLastNotificationDate(Guid userID, DateTime dateTime);
        DateTime GetLastNotificationDate(Guid userID);                        
    }
}
